(function ( exports ) {

    //region ExecuteWorkflow

    /**
     * Execute workflow
     * @prop {string} id Process Session unique identifier (GUID)
     * @memberOf COSA.Response
     * @constructor ExecuteWorkflow
     */
    function ExecuteWorkflow () {
        COSA.Response.ResponseBase.call(this, COSA.Const.Message.ExecuteWorkflow);

        this.id = null;
    }

    COSA.Util.derivePrototype(COSA.Response.ResponseBase, ExecuteWorkflow);

    ExecuteWorkflow.prototype.parseResponse = function ( responseBody ) {
        this.id = responseBody.node('KeyValuePairOfstringanyType.value').text();
    };

    //endregion ExecuteWorkflow

    //region Assign

    /**
     * Assign response
     * @memberOf COSA.Response
     * @constructor Assign
     */
    function Assign () {
        COSA.Response.ResponseBase.call(this, COSA.Const.Message.Assign);
    }

    COSA.Util.derivePrototype(COSA.Response.ResponseBase, Assign);

    //endregion Assign

    //region SetState

    /**
     * SetState response
     * @memberOf COSA.Response
     * @constructor SetState
     */
    function SetState () {
        COSA.Response.ResponseBase.call(this, COSA.Const.Message.SetState);
    }

    COSA.Util.derivePrototype(COSA.Response.ResponseBase, SetState);

    //endregion SetState

    //region LoseOpportunity

    /**
     * LoseOpportunity response
     * @memberOf COSA.Response
     * @constructor LoseOpportunity
     */
    function LoseOpportunity () {
        COSA.Response.ResponseBase.call(this, COSA.Const.Message.LoseOpportunity);
    }

    COSA.Util.derivePrototype(COSA.Response.ResponseBase, LoseOpportunity);

    //endregion LoseOpportunity

    //region WinOpportunity

    /**
     * WinOpportunity response
     * @memberOf COSA.Response
     * @constructor WinOpportunity
     */
    function WinOpportunity () {
        COSA.Response.ResponseBase.call(this, COSA.Const.Message.WinOpportunity);
    }

    COSA.Util.derivePrototype(COSA.Response.ResponseBase, WinOpportunity);

    //endregion WinOpportunity

    //region AddListMembersList

    /**
     * AddListMembersList response
     * @memberOf COSA.Response
     * @constructor AddListMembersList
     */
    function AddListMembersList () {
        COSA.Response.ResponseBase.call(this, COSA.Const.Message.AddListMembersList);
    }

    COSA.Util.derivePrototype(COSA.Response.ResponseBase, AddListMembersList);

    //endregion AddListMemberList

    //region AddMemberList

    /**
     * AddMemberList response
     * @prop {string} Unique identifier (GUID)
     * @memberOf COSA.Response
     * @constructor AddMemberList
     */
    function AddMemberList () {
        COSA.Response.ResponseBase.call(this, COSA.Const.Message.AddMemberList);

        this.id = '';
    }

    COSA.Util.derivePrototype(COSA.Response.ResponseBase, AddMemberList);

    AddMemberList.prototype.parseResponse = function ( responseBody ) {
        this.id = responseBody.node('KeyValuePairOfstringanyType.value').text();
    };

    //endregion AddMemberList

    //region CopyMembersList

    /**
     * CopyMembersList response
     * @memberOf COSA.Response
     * @constructor CopyMembersList
     */
    function CopyMembersList () {
        COSA.Response.ResponseBase.call(this, COSA.Const.Message.CopyMembersList);
    }

    COSA.Util.derivePrototype(COSA.Response.ResponseBase, CopyMembersList);

    //endregion CopyMembersList

    //region RemoveMemberList

    /**
     * RemoveMemberList response
     * @memberOf COSA.Response
     * @constructor RemoveMemberList
     */
    function RemoveMemberList () {
        COSA.Response.ResponseBase.call(this, COSA.Const.Message.RemoveMemberList);
    }

    COSA.Util.derivePrototype(COSA.Response.ResponseBase, RemoveMemberList);

    //endregion RemoveMemberList

    //region RetrieveUserPrivileges

    /**
     * RetrieveUserPrivileges response
     * @prop {string} rolePrivileges Role privileges
     * @memberOf COSA.Response
     * @constructor RetrieveUserPrivileges
     */
    function RetrieveUserPrivileges () {
        COSA.Response.ResponseBase.call(this, COSA.Const.Message.RetrieveUserPrivileges);

        this.rolePrivileges = null;
    }

    COSA.Util.deriveOverride(COSA.Response.ResponseBase, RetrieveUserPrivileges, {
        parseResponse: function ( responseBody ) {
            var itms = responseBody.keyValueCollection();

            this.rolePrivileges = (new COSA.RolePrivilegeCollection()).deserialize(itms.RolePrivileges);
        }
    });

    //endregion RetrieveUserPrivileges

    //region RetrievePrincipalAccess

    /**
     * RetrievePrincipalAccess response
     * @prop {string} accessRights Access Rights
     * @memberOf COSA.Response
     * @constructor RetrievePrincipalAccess
     */
    function RetrievePrincipalAccess () {
        COSA.Response.ResponseBase.call(this, COSA.Const.Message.RetrievePrincipalAccess);

        this.accessRights = '';
    }

    COSA.Util.deriveOverride(COSA.Response.ResponseBase, RetrievePrincipalAccess, {
        parseResponse: function ( responseBody ) {
            var itms = responseBody.keyValueCollection();

            this.accessRights = itms.AccessRights.text();
        }
    });

    //endregion RetrievePrincipalAccess

    //region QualifyLead

    /**
     * QualifyLead response
     * @prop createdEntities
     * @memberOf COSA.Response
     * @constructor QualifyLead
     */
    function QualifyLead () {
        COSA.Response.ResponseBase.call(this, COSA.Const.Message.QualifyLead);

        this.createdEntities = null;
    }

    COSA.Util.deriveOverride(COSA.Response.ResponseBase, QualifyLead, {
        parseResponse: function ( responseBody ) {
            var itms = responseBody.keyValueCollection();

            this.createdEntities = (new COSA.EntityReferenceCollection()).deserialize(itms.CreatedEntities);
        }
    });

    //endregion QualifyLead

    exports.ExecuteWorkflow = ExecuteWorkflow;
    exports.Assign = Assign;
    exports.SetState = SetState;
    exports.LoseOpportunity = LoseOpportunity;
    exports.WinOpportunity = WinOpportunity;
    exports.AddListMembersList = AddListMembersList;
    exports.AddMemberList = AddMemberList;
    exports.CopyMembersList = CopyMembersList;
    exports.RemoveMemberList = RemoveMemberList;
    exports.RetrieveUserPrivileges = RetrieveUserPrivileges;
    exports.RetrievePrincipalAccess = RetrievePrincipalAccess;
    exports.QualifyLead = QualifyLead;

})(COSA.Response);
